﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;

namespace Axial.Tests
{
	[TestFixture]
	class ContinueTests : TestBase
	{
		[Test]
		public void IfContinueTest()
		{
			VerifyMethodOutput("IfContinue",
@"a = 0;
while (a < 5)
{
	if (a > 3)
		continue;
	a = a + 1;
}");
		}
		public void IfContinue()
		{
			int a = 0;
			while (a < 5)
			{
				if (a > 3)
					continue;
				a++;
			}
		}

		[Test]
		public void IfAndOrContinueTest()
		{
			VerifyMethodOutput("IfAndOrContinue",
@"a = 0;
b = 1;
c = 2;
while (a < 5)
{
	if (a > 3 && b == 1 || c <= 3)
		continue;
	a = a + 1;
}");
		}
		public void IfAndOrContinue()
		{
			int a = 0;
			int b = 1;
			int c = 2;
			while (a < 5)
			{
				if (a > 3 && b == 1 || c <= 3)
					continue;
				a++;
			}
		}

		[Test]
		public void IfStatementIfContinueTest()
		{
			VerifyMethodOutput("IfStatementIfContinue",
@"a = 0;
while (a < 5)
{
	a = a + 1;
	if (a > 3)
	{
		a = a - 1;
		if (a < 3)
			continue;
	}
	a = a + 1;
}");
		}
		public void IfStatementIfContinue()
		{
			int a = 0;
			while (a < 5)
			{
				a++;
				if (a > 3)
				{
					a--;
					if (a < 3)
						continue;
				}
				a++;
			}
		}

		[Test]
		public void IfStatementContinueTest()
		{
			VerifyMethodOutput("IfStatementContinue",
@"a = 0;
while (a < 5)
{
	a = a + 1;
	if (a > 3)
	{
		a = a - 1;
		continue;
	}
	a = a + 1;
}");
		}
		public void IfStatementContinue()
		{
			int a = 0;
			while (a < 5)
			{
				a++;
				if (a > 3)
				{
					a--;
					continue;
				}
				a++;
			}
		}

		[Test]
		public void IfContinueIfContinueTest()
		{
			VerifyMethodOutput("IfContinueIfContinue",
@"a = 0;
b = 0;
while (a < 5)
{
	if (a > 3)
	{
		b = 2;
		continue;
	}
	a = a + 1;
}
b = a;
while (b < 5)
{
	if (b > 3)
	{
		a = 3;
		continue;
	}
	b = b + 1;
}");
		}
		public void IfContinueIfContinue()
		{
			int a = 0;
			int b = 0;
			while (a < 5)
			{
				if (a > 3)
				{
					b = 2;
					continue;
				}
				a++;
			}
			b = a;
			while (b < 5)
			{
				if (b > 3)
				{
					a = 3;
					continue;
				}
				b++;
			}
		}

		[Test]
		public void StatementIfAndContinueTest()
		{
			VerifyMethodOutput("StatementIfAndContinue",
@"while (a < 10)
{
	a = a + 1;
	if (a == 5 && b == 3)
		continue;
	a = a + 1;
}");
		}
		public void StatementIfAndContinue()
		{
			int a = 0;
			int b = 1;
			while (a < 10)
			{
				a++;
				if (a == 5 && b == 3)
					continue;
				a++;
			}
		}

		[Test]
		public void IfContinueElseBreakTest()
		{
			VerifyMethodOutput("IfContinueElseBreak",
@"var a;
a = 0;
while (a < 10)
{
	a = a + 1;
	if (a == 5)
		continue;
	a = a + 1;
	break;
}
a = a + 1;");
		}
		public void IfContinueElseBreak()
		{
			int a = 0;
			while (a < 10)
			{
				a++;
				if (a == 5)
					continue;
				a++;
				break;
			}
			a++;
		}

	}
}
